<%--
 *  File:   ProdPopWindow.jsp
 *  Desc:	expensetype pop for report page
 *
 *  Date		   Author		  Changes
 *  2009-12-28	  visazhou		  Modify
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "ALL";
  String strTableName = "v_product";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<html>
<head>
<title>ProdPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_productpop"/>

<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
    int totalsize  = totalsummary.size();
%>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
<%--  put your custom script here   --%>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "ProdPopWindow.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.id.value = eval('obj.all.id'+idx).value;
}

function page_done(){
   for(var i = 0; i <<%=totalsize%>; i++){
    if(document.getElementById('prodid'+i).checked){
      	if(isEmpty(document.cform.selectedprodid.value)){
        	document.cform.selectedprodid.value = document.getElementById('prodid'+i).value;
      	}else{
      	    document.cform.selectedprodid.value = document.cform.selectedprodid.value + "," + document.getElementById('prodid'+i).value;;
      	}
      
      	if(isEmpty(document.cform.selectedprodcode.value)){
       		document.cform.selectedprodcode.value = document.getElementById('prodcode'+i).value;
     	}else{
        	document.cform.selectedprodcode.value = document.cform.selectedprodcode.value + "," + document.getElementById('prodcode'+i).value;;
      	}

      	if(isEmpty(document.cform.selectedprodname.value)){
        	document.cform.selectedprodname.value = document.getElementById('prodname'+i).value;
      	}else{
        	document.cform.selectedprodname.value = document.cform.selectedprodname.value + "," + document.getElementById('prodname'+i).value;;
      	}
    }
  }

  if(document.cform.selectedprodid.value != ""){
      opener.page_setProduct(document.cform.selectedprodid.value,document.cform.selectedprodcode.value,document.cform.selectedprodname.value);  
  }
  window.close();
}

function page_close(){
	window.close();
}
</script>
</head>

<body>
<div id=div2 style="HEIGHT: 415px; OVERFLOW: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_productpop">
<input type="hidden" name="actionname">  
<custom:hidden property="selectedprodid"/> 
<custom:hidden property="selectedprodcode"/>
<custom:hidden property="selectedprodname"/>
 
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
            <%@ include file="/inc/SummarySearch.inc" %>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td width="26" class="title_center">&nbsp;</td>
          <td width="180" class="title_center"><a href="javascript:page_summary('orderby','prodcode')"><%= label.getLabelName("L_ProdCode") %></a></td>
          <td class="title_center" width="295"><a href="javascript:page_summary('orderby','prodname')"><%= label.getLabelName("L_ProductName") %></a></td>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
           	
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<td width="5">
              		<input id="prodid<%= idx %>" type="radio"  name="prodids" value="<%=JspHelper.filterNull( tempMap.get("prodid") )%>" class="checkbox">
            	</td>
            	<td>
            		<custom:write name="onerow" property="prodcode"/>
            	</td>
            	<td>
            		<custom:write name="onerow" property="prodname"/>
            	</td>
              		<custom:hidden name="onerow" property="prodcode" colIndex="<%= idx %>" />
              		<custom:hidden name="onerow" property="prodname" colIndex="<%= idx %>" />
     		 </tr>
     	 </logic:iterate>

            <%@ include file="/inc/SummaryAction.inc" %>
          </table>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                <a onclick="page_done();"><custom:button type="1" label="L_Ok" imgsrc="add.gif" border="0" style="width:60"/></a>
              	<a onclick="page_close();"><custom:button type="1" label="L_Close" imgsrc="close.gif" border="0" style="width:60"/></a>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</div>
</body>
</html>